﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MShop.Core.DataAccess;
using MShop.Core.Domain;
using MShop.Core;
using MShop.Web.Components.Paging;

namespace MShop.Web.Controllers
{
    public class OccasionController : ControllerBase
    {
        private readonly IProductDao _ProductDao;
        private readonly IItemCatDao _ItemCatDao;
        private readonly ICommonDao<Occasion> _OccasionDao;
        private readonly ICommonDao<OccasionProduct> _OccasionProductDao;     
        private readonly ICartItemDao _CommonDao;
        private readonly IShopContext _IShopContext;
        private readonly IDictDao _DictDao;
        public OccasionController(IProductDao productDao, IItemCatDao itemcatdao, ICommonDao<Occasion> occasionDao, ICommonDao<OccasionProduct> occasionProductDao, ICartItemDao commonDao, IShopContext shopContext, IDictDao dictDao)
        { 
            _ItemCatDao = itemcatdao;
            _ProductDao = productDao;
            _OccasionDao = occasionDao;
            _OccasionProductDao = occasionProductDao;
            _CommonDao = commonDao;
            _IShopContext = shopContext;
            _DictDao = dictDao;
        }

        public ActionResult Index(int? page,int? oid)
        {
            AppendMeta("场合选酒","红酒,意大利葡萄酒,法国红酒,葡萄酒,礼物,拉菲","根据不同场合选择不一样的酒");

            IList<Occasion> list= _OccasionDao.GetAll().ToList();
            ViewData["oids"] =list;
            if (oid.HasValue == false)
            {
                return View(_OccasionProductDao.GetAll());                
            }
            else if (oid.Value == -1)
            {
                return View(_OccasionProductDao.GetAll());
            }
            else
            {
                return View(_OccasionProductDao.Find(x => x.OId == oid.Value));
            }
        }
    }
}
